<?php
require_once("../../resources/commons.php");
require_once("../../data/User.php");
require_once("../../data/Report.php");

SessionManager::getInstance()->checkSession();
displayTop("Archived reports","../../resources/ajaxscripts.php",null);

//If "full" parameter is set to "1" then display all the reports
if($_REQUEST["full"]=="1"){
	$l_selectionStatement="where User_Id=:User_Id order by createdDate desc";
?>
<h1>All the reports</h1>
<?php
}else{
	//Do not display all the reports (only reports published in the last 100 days)
	$l_selectionStatement="where DATEDIFF(NOW(),createdDate)<120 and User_Id=:User_Id order by createdDate desc";
?>
<h1>Reports from the last 100 days</h1>
<p>
<a href="manage_reports.php?full=1">Display all the reports</a>
</p>
<?php
}
$l_reports=Report::getFromCustomCriteria($l_selectionStatement,array("User_Id" => SessionManager::getCurrentLoggedUserId()));
if(count($l_reports)!=0){
	$l_reportsTable=new TableData("ReportsTable");
	$l_reportsTable->addHeader("createdDate","Report creation date");
	$l_reportsTable->addHeader("validatedLabel","Validated");
	$l_reportsTable->setRecords($l_reports);
	$l_reportsTable->setZoomArea("ajax_report_details.php");
	displayTable($l_reportsTable);
}
displayBottom();
?>